package chapter_9;


public class JoinThread extends Thread{
    private String name;

    public JoinThread(String name){
        this.name = name;
    }
    @Override
    public void run()
    {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name);
    }

    public static void main(String[] args) throws InterruptedException {
        JoinThread joinThread = new JoinThread("first");
        joinThread.start();
        joinThread.join();

        JoinThread joinThread2 = new JoinThread("second");
        joinThread2.start();
        joinThread2.join();

        System.out.println("main");
    }
}
